package com.example.rabbitmq.comsumer.direct;

import com.example.common.config.RabbitMQConfig;
import com.example.common.model.User;
import java.util.Map;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 异步接收消息
 *
 * @author chenzhian
 * @version 0.1.0
 * @since 0.1.0
 */
@Component
@RabbitListener(queues = {RabbitMQConfig.RABBITMQ_DEMO_TOPIC})
public class RabbitMQConsumer {

  @RabbitHandler
  public void process(Map map) {
    System.out.println("消费者RabbitMQConsumer从RabbitMQ服务消费信息：" + map.toString());
  }

  /**
  * 接收Object
  */
  @RabbitHandler
  public void process(User user) {
    System.out.println("Receive Object: " + user);
  }
}
